<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<title>借款申请财务审批信息</title>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/meta.jsp"%>
<style type="text/css">
#top1_left{ width:800px;  float:left; _margin-right:-3px; margin-left: 10px;}
#top1_right{float:right;}
</style>
</head>
<body>
<div class="x-panel" style="width: 100%;">
<div class="x-panel-header">借款申请财务审批</div>
<div style="width: 100%;">

 <table width="100%" >
  <tr>
	  <td>
		<div style="width:450px; border: 0px solid #c3daf9; float: left; margin-left: 10px;">
		  <s:hidden name="model.id" />
		  <table border="1" cellpadding="0" cellspacing="0" style="padding:10px 10px 10px 10px;border-collapse: collapse; border-left-width:0px; border-top-width:0px; padding: 4px 2px; margin-top: 5px;">
		    <c:set value="${borrow}" var="borrow" scope="request"/>	
		    <c:set value="${flow}" var="flow" scope="request"/>
		    <c:set value="${node}" var="node" scope="request"/>
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="center" colspan="4"><font size="3">借款单</font></td>
	        </tr>	
			<tr height="20" style="padding: 8px 2px; padding-left: 13px;"> 
	           <td align="left" colspan="4">借款部门：
	           ${borrow.dept.name}
	           &nbsp;&nbsp;借款人：${borrow.borrower.name}
	           &nbsp;&nbsp;借款时间： ${borrow.createDate}</td>
	        </tr>	
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="80">借款单号：</td>
	           <td align="left" colspan="3">${borrow.singleNo}</td>
	        </tr>         
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="right" width="80">摘&nbsp;&nbsp;&nbsp;&nbsp;要：</td>
	           <td align="left" colspan="3">${borrow.title}</td>
	        </tr>        
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="right">项目名称：</td>
	           <td align="left" colspan="3" width="720"> ${borrow.project.name}</td>
	        </tr>
	        
			<tr height="20" style="padding: 8px 2px;"> 
	           <td align="right">财务科目：</td>
	           <td align="left" width="200">${borrow.item.name}</td>
				<td align="right" >金&nbsp;&nbsp;额：</td> 
				<td width="80">${borrow.amount}</td>
	        </tr>	
			<tr height="20" style="padding: 8px 2px;"> 
				<td align="right">备&nbsp;&nbsp;&nbsp;&nbsp;注：</td>
				<td align="left" colspan="3" style="padding-left: 0px;">${borrow.descn}</td>
			</tr>
			
		   </table>
		   
			<s:form action="save" id="save" validate="true" method="POST">
		    <s:hidden name="model.id" id="flowId"/>
		    <input type="hidden"" id="projectId" value="${borrow.project.id}">
		    <fieldset style="width: 450px; padding:10px 10px 10px 10px;">
            <legend>【<stc:userdept></stc:userdept>】</legend>
			<table width="100%" align="left">
			  <tr height="20">
				<td align="right" width="100">&nbsp;&nbsp;&nbsp;审&nbsp;核&nbsp;人：</td>
				<td align="left" width="90">
				    <stc:username></stc:username>
				</td>
				<td align="right" width="100">审批时间：</td>
				<td align="left" width="400">
				    ${audDate}
				</td>
			  </tr>	  
			  <tr height="20">
			    <td align="right">是否通过：</td>
			    <td colspan="3">
			    	<s:radio list="isAgreeMap" id="isAgree" name="isAgree" onchange="setAgreeValue(this.value)"  cssStyle="border:0px;"/> 
		            <font color="red">*</font>
		        </td>
			  </tr>
			  <tr height="20">
			    <td align="right">具体意见：</td>
				<td align="left" colspan="3">
				  <textarea rows="4" name="descn" style="width:300px;" id="descn" ></textarea>
				  <font color="red">*</font>
			    </td>
			  </tr>
			  	
			</table>
			</fieldset>
			</s:form>
		
			<table width="100%">
				<tr>
					<td style="text-align: center;">
		                <input type="button" value="保存" class="button" onclick="return auditSave()"/>&nbsp;&nbsp;
						<s:reset value="返回" cssClass="button" onclick="javascript:history. back();" />
					</td>
				</tr>
			</table>				
		</div>
	  </td>  
	  <td>	
		<div>
           <iframe name="iframe_borrow" id="iframe_borrow" src="${ctx}/borrow/viewIndex.do?borrowerId=${borrow.borrower.id}" style="HEIGHT:100%; WIDTH: 360px;" frameborder="0" scrolling="no"></iframe>
		</div>
	  </td>
   </tr>
</table>
</div>
</div>

<script type="text/javascript">
var agreeVal = null;
function setAgreeValue(aValue) {
	agreeVal = aValue;
}	
function auditSave() {
	var type = "borrow";
	var projectId = document.getElementById("projectId").value;
	var fId = document.getElementById("flowId").value;
	var descn = document.getElementById("descn").value;
	if (agreeVal == null || agreeVal == "") {
		alert("请您选择审批是否通过！");
		return false;
	}
	if (descn == null || descn == "") {
		alert("请您填写具体意见！");
		return false;
	}
	if (confirm("您确认要审批此借款申请单吗？")){
  	     $.ajax({
			url: '${ctx}/flow/saveAuditResult.do',
			type: 'post',
			dataType: 'json',
			data: {type : type, flowId : fId, isAgree : agreeVal, descn: descn},
			success: function(rst, textStatus){
	  		  if(rst.result == "success"){
	  			window.location = '${ctx}/flow/borrowIndex.do';	      	  		
	  	  	  }else{
	  	  		alert("审核失败，请重试...");
	  	  	  }
			}
	  	 });		
		return true;
	}else {
		return false;
	}
}	
</script>
</body>
</html>